unit_test_v2.c

/*
 * Unit Test Bootstrap
 * Autor: Tomasz Jaworski, 2018-2019
 *
 * Test dla zadania Histogram
 * Autor testowanej odpowiedzi: Szymon Ptak
 * Test wygenerowano automatycznie o 2019-08-21 22:21:40.233272
 *
 * Debug: 
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <signal.h>
#include <setjmp.h>
#include <assert.h>

#define _RLDEBUG_API_
#include "unit_helper_v2.h"
#include "rdebug.h"

#include "tested_declarations.h"
#include "rdebug.h"

//
// Elementy globalne dla całego testu
//




//
//  Test 1: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST1(void)
{
    // informacje o teście
    test_start(1, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {0, 0, 0, 0, 1, 1, 2, 0, 0, 3, 0};
                int output[] = {-2, 2, 1, 1, -2, 2, -2, -2, 1, 2, 0};
        
                printf("#####START#####");
                int res = create_histogram((float[]){9.215964, 6.264129, 5.113955, 4.841200, 9.309356, 6.994210, 9.960774}, 7, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [0, 0, 0, 0, 1, 1, 2, 0, 0, 3, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 2: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST2(void)
{
    // informacje o teście
    test_start(2, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {6, 5, 2, 7, 6, 7, 4, 2, 2, 2, 5};
                int output[] = {1, 1, 0, 2, 2, -2, -1, 0, -2, 0, 2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){5.683580, 4.912332, 10.108805, 6.654395, 5.439473, 10.214364, 1.705667, 0.978603, 0.963332, 5.566225, 9.005779, 7.667163, 0.696238, 5.575824, 4.172711, 4.414917, 6.149757, 3.827939, 8.036415, 0.630272, 3.588389, 4.618793, 7.045249, 0.395406, 3.364684, 3.856382, 1.502151, 0.215177, 5.495951, 5.873402, 4.547403, 1.222762, 2.761555, 8.204824, 10.720689, 5.368973, 2.135235, 4.898367, 3.338294, 1.682373, 10.777747, 10.335371, 6.012341, 3.015722, 3.134668, 1.265605, 9.572211, 6.386546}, 48, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [6, 5, 2, 7, 6, 7, 4, 2, 2, 2, 5]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 3: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST3(void)
{
    // informacje o teście
    test_start(3, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {13, 22, 13, 19, 9, 22, 17, 18, 17, 19, 15};
                int output[] = {-1, 2, -2, 0, 2, -1, 2, -2, 1, -1, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){5.197958, 5.447261, 4.349666, 3.756765, 10.968129, 8.572674, 5.937958, 9.007744, 9.769770, 1.318064, 6.254581, 8.845523, 7.797367, 9.519656, 6.502017, 4.284350, 3.219253, 9.488799, 5.540047, 5.215050, 3.068440, 5.764675, 0.918056, 5.623656, 3.962700, 10.332118, 7.101014, 10.210212, 9.372233, 6.009875, 1.211283, 4.017134, 5.693506, 6.077344, 3.777107, 7.408812, 0.118667, 2.448075, 5.761032, 3.305393, 1.318289, 6.235954, 4.090457, 9.367535, 6.851641, 0.810330, 7.032234, 4.988366, 3.238463, 0.752311, 7.041049, 2.300878, 7.875405, 9.498777, 7.456073, 2.209306, 2.324426, 8.790493, 3.737381, 10.970052, 1.365929, 8.905759, 0.706581, 6.383044, 7.099374, 4.095740, 3.407562, 6.704854, 1.795016, 2.482021, 0.717399, 10.663646, 7.647332, 1.794786, 9.770488, 5.167602, 8.818225, 1.559178, 6.427958, 8.416220, 9.585509, 3.084832, 9.806295, 3.026433, 1.719745, 6.646558, 3.452936, 9.208083, 7.385927, 3.451699, 6.382867, 2.746894, 8.362551, 8.699197, 7.609556, 5.573522, 8.119869, 9.648103, 9.412917, 10.890906, 2.119904, 3.937189, 3.527037, 9.812383, 7.582796, 0.966805, 0.657943, 6.670969, 1.978120, 7.459020, 2.034226, 5.711326, 8.849130, 8.688807, 1.509151, 8.357970, 8.836058, 7.862500, 0.009211, 5.010230, 6.892558, 4.378277, 2.755964, 10.395089, 9.505666, 3.890561, 10.881165, 5.059025, 6.290875, 2.618940, 7.127939, 9.664767, 9.206606, 2.323311, 1.869960, 2.856729, 4.403854, 10.806104, 1.287928, 10.521088, 1.857284, 5.349911, 5.103178, 5.138132, 5.126003, 6.644749, 2.924331, 10.943683, 1.421772, 0.963386, 10.349097, 1.350814, 10.641243, 5.811873, 9.995845, 1.460266, 5.611557, 7.929418, 1.650625, 8.674658, 1.208718, 10.676518, 7.799109, 3.214367, 1.457903, 0.336347, 6.512295, 1.836667, 9.039348, 5.317657, 4.474413, 1.993184, 3.431245, 7.236321, 1.490706, 8.532910, 8.054414, 3.327729, 6.525914, 10.566506, 8.991774, 0.207690, 5.329071, 0.666614}, 184, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [13, 22, 13, 19, 9, 22, 17, 18, 17, 19, 15]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 4: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST4(void)
{
    // informacje o teście
    test_start(4, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0};
                int output[] = {-2, -2, -2, 2, -2, 1, -1, 2, -2, 0, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){0.170681, -2.258885, 8.670344, 4.958677, -8.732324}, 5, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 5: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST5(void)
{
    // informacje o teście
    test_start(5, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {4, 5, 6, 3, 6, 3, 5, 3, 4, 4, 0};
                int output[] = {2, 2, -2, -1, 1, 0, 1, 2, 2, 1, 2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){-2.352433, 6.332525, -6.253813, -6.247546, -2.582223, 7.710601, -4.366715, 7.781579, 2.556301, -3.955491, -5.093317, -5.271560, 2.456721, -1.890076, -8.234567, -2.923805, -7.103816, 8.013060, 5.066871, -6.833690, 9.928885, -1.815723, -3.892376, 5.556291, -4.162659, 4.094222, -7.294124, -6.156434, -1.563082, 9.398085, 3.257119, -1.202529, 3.632864, -8.498353, 6.092091, -2.832096, -7.122698, -4.644701, 4.708455, 1.106971, -7.186027, 7.582278, 8.025024, -4.997371, -6.075307, 0.163748, -0.835865, -3.557886, 5.638820, -3.575215, -7.478396, -3.679806, -5.708463, 1.768817, -4.523050, 9.836686, 0.557511, 6.036246, 4.274136, -0.998190, 8.470842, 0.873385, 2.514160, 9.117092, 2.317708, 2.864794, -5.400848, -2.309225, 4.115587, 4.624324, -8.220844, -4.474818, 1.968185, 6.772629, -3.280800, -6.651618, -8.547718, -6.551070, 1.761634, 8.916008, -7.499465, -1.821886, -0.510760, -4.499834, 3.991978, 2.504961, 1.868086, -0.646833, 6.912399, 4.947627, -4.168391, -8.180962, -7.070812, 0.542993, -4.215096}, 95, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [4, 5, 6, 3, 6, 3, 5, 3, 4, 4, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 6: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST6(void)
{
    // informacje o teście
    test_start(6, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {4, 8, 4, 7, 1, 6, 5, 5, 4, 7, 4, 5, 3, 5, 2, 4, 5, 4, 4, 8, 0};
                int output[] = {-1, -2, -2, 1, 0, -2, 2, 2, -2, 0, 0, 2, -2, -2, 1, 0, -2, 2, -2, -2, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){7.140117, 17.190397, 0.184002, 19.728390, 5.217122, 15.936582, 9.257509, 1.079720, 3.820596, 13.088655, 11.860966, 9.475740, 3.056448, 1.402987, 14.517598, 19.787171, 1.717470, 12.784495, 11.810370, 10.485952, 5.915624, 3.887688, 5.262498, 1.692804, 1.730936, 3.391897, 16.166102, 2.968707, 7.301047, 9.780172, 7.023653, 9.296015, 19.759206, 3.650233, 6.160867, 19.771916, 2.369075, 18.893924, 8.809581, 6.368273, 2.423158, 17.052546, 18.507670, 4.440750, 6.500140, 6.754297, 16.772530, 7.728304, 0.843795, 3.699378, 12.058628, 15.868532, 16.345330, 19.830125, 1.530751, 16.177811, 8.716080, 3.291109, 16.348579, 0.080028, 13.756030, 19.206859, 8.891916, 8.727464, 13.363265, 7.680912, 14.459153, 9.459178, 17.879915, 6.466465, 5.943250, 18.184162, 5.269258, 19.966504, 10.152542, 18.977072, 15.423755, 19.328212, 0.027655, 12.050583, 1.527619, 15.034836, 11.483834, 10.813926, 11.490021, 1.911155, 13.933492, 10.848345, 9.614612, 2.860116, 5.802785, 17.281259, 13.882962, 11.347072, 9.185892}, 95, output, 21);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 21; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [4, 8, 4, 7, 1, 6, 5, 5, 4, 7, 4, 5, 3, 5, 2, 4, 5, 4, 4, 8, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 21; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 7: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST7(void)
{
    // informacje o teście
    test_start(7, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {14, 12, 5, 16, 11, 11, 9, 12, 13, 12, 14, 15, 14, 13, 11, 7, 8, 8, 12, 11, 17, 9, 11, 8, 8, 13, 9, 11, 8, 14, 17, 5, 11, 12, 13, 7, 12, 7, 9, 7, 9, 10, 15, 16, 11, 14, 16, 11, 8, 13, 11, 6, 6, 8, 8, 14, 12, 10, 6, 11, 9, 5, 9, 8, 8, 0};
                int output[] = {1, 0, 2, -2, -1, 1, 1, 2, -1, 1, 1, 1, 2, 1, -1, -2, -2, -1, 1, 0, -2, -1, -1, -2, 1, 1, 2, 1, -1, -2, 1, 0, -1, -1, 2, 2, 2, 0, 2, -2, -1, 1, -1, 0, -2, -1, -2, 1, 0, 1, -2, 0, -2, 2, 1, -2, 2, -1, -2, -2, -1, 0, 2, -1, -2, 1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){19.407415, 32.636971, 60.020481, 8.854885, 20.223969, 32.786909, 5.779968, 4.154734, 29.713337, 9.850884, 25.966451, 50.467912, 43.746767, 20.460184, 17.819306, 33.763036, 51.090767, 24.143789, 58.418377, 52.123526, 26.745698, 6.749251, 40.213672, 44.974563, 53.546971, 13.234024, 12.571026, 29.388042, 35.464144, 12.067611, 49.901614, 37.993012, 55.350876, 23.852313, 4.218993, 11.907237, 22.161063, 21.109925, 18.140352, 33.005544, 56.346462, 62.020666, 2.755507, 38.624623, 18.501987, 9.454654, 42.919501, 27.271695, 31.047185, 60.634942, 59.940072, 34.762009, 31.203950, 25.218085, 58.274616, 62.645792, 19.818725, 44.729301, 18.972822, 14.018642, 59.196974, 28.497016, 15.482912, 4.014757, 34.718506, 13.675838, 54.090864, 29.343501, 28.605503, 28.804660, 37.481848, 60.638010, 54.122191, 26.270154, 21.299222, 7.692946, 25.163591, 55.830581, 55.129578, 22.719405, 60.240782, 9.406836, 49.293942, 28.016674, 32.944866, 46.299061, 22.239648, 22.781925, 0.262974, 42.994812, 45.562522, 14.318362, 3.149098, 21.851052, 7.283623, 6.355694, 7.356257, 62.008548, 3.179313, 43.190604, 21.750625, 7.288612, 37.319650, 20.744826, 22.427198, 10.902123, 49.859372, 36.017941, 17.896925, 32.061156, 4.249328, 34.790527, 60.426952, 50.286521, 59.585763, 56.379158, 7.022879, 47.012146, 25.416768, 11.889899, 30.979053, 1.205050, 37.117140, 30.368079, 1.262812, 62.451112, 43.541053, 46.242211, 63.607385, 37.243888, 10.149416, 18.499999, 64.572072, 41.490662, 54.705022, 28.145529, 54.043397, 5.450685, 2.250033, 14.754795, 36.109301, 22.657789, 1.316650, 56.894689, 57.666536, 18.388970, 28.643493, 32.569371, 7.582679, 64.794680, 6.761204, 23.457508, 8.120645, 19.962358, 13.825820, 38.531517, 7.065794, 42.895124, 0.466471, 29.705225, 35.781986, 49.810776, 23.403837, 64.203785, 38.432512, 3.760797, 36.933564, 28.712449, 48.649651, 50.440325, 54.395025, 6.100349, 18.724703, 16.048989, 36.097978, 12.234101, 0.717151, 19.160675, 39.624777, 4.793766, 18.201419, 40.347504, 1.069635, 16.609055, 24.913387, 4.210887, 20.986348, 43.584793, 49.546711, 27.383882, 49.669530, 45.882737, 51.031448, 20.303869, 42.290641, 55.099800, 22.996713, 48.665622, 20.969122, 14.927944, 50.646860, 57.167884, 4.900919, 30.562101, 3.992763, 34.832755, 34.278113, 53.280233, 10.800419, 29.488695, 33.706742, 13.665657, 29.138382, 0.175470, 13.559113, 18.771891, 0.065116, 23.221130, 34.137059, 7.461999, 59.848432, 3.217217, 8.994087, 62.195099, 13.740953, 24.451290, 10.018046, 25.713046, 5.428260, 8.773173, 8.995681, 64.172084, 30.742646, 5.272943, 53.473727, 30.060621, 3.321384, 57.488537, 30.684305, 50.231897, 50.193736, 20.693308, 33.055956, 3.777655, 11.035245, 55.655753, 59.517955, 35.783108, 47.514834, 16.832723, 10.837786, 21.850673, 53.192201, 56.243499, 23.266567, 42.702648, 51.016307, 13.316274, 24.415075, 51.011985, 60.785711, 34.236349, 63.961513, 52.940673, 34.547139, 55.481744, 47.750417, 30.813500, 3.954542, 56.110871, 40.491810, 14.383733, 60.701287, 30.391601, 38.320238, 3.579675, 15.222108, 55.599073, 3.933676, 27.106585, 59.891470, 40.664127, 20.086161, 44.270608, 13.496747, 59.446024, 9.828650, 32.213657, 12.866574, 57.957440, 56.009179, 51.040629, 47.125840, 37.386150, 16.401429, 5.425628, 20.148720, 21.212511, 1.325320, 46.366746, 64.588131, 49.720611, 6.809184, 8.635242, 56.762825, 10.271232, 13.484476, 53.615179, 42.529452, 10.847398, 41.062880, 2.912949, 30.253230, 32.993895, 3.865245, 5.086367, 21.546866, 35.602331, 63.928118, 12.423522, 44.664842, 56.484963, 39.084125, 45.114271, 47.387518, 58.021493, 46.084101, 18.773508, 3.850313, 45.120583, 34.793835, 25.880478, 62.038645, 40.376727, 60.210443, 46.497628, 18.382307, 11.354377, 8.606453, 33.770204, 61.991083, 55.137856, 19.089940, 34.267087, 19.438432, 11.309701, 16.995454, 57.593343, 53.753024, 29.317614, 2.432907, 15.690017, 22.965440, 55.969332, 43.687290, 30.775454, 7.098384, 41.369731, 43.932232, 32.028361, 19.110505, 27.835412, 31.399838, 45.641744, 12.176161, 44.486875, 14.939434, 17.230343, 9.710288, 11.053584, 3.319216, 23.929733, 18.033374, 31.168364, 48.590030, 46.086331, 13.156455, 0.341677, 46.775216, 55.624459, 33.245763, 6.031565, 49.949390, 30.535066, 17.538652, 12.795752, 54.093650, 12.896968, 33.300186, 29.017612, 11.094752, 46.224777, 12.651686, 55.726288, 11.845181, 37.463576, 42.871028, 16.836148, 5.424165, 40.580640, 1.437010, 7.328835, 20.833669, 43.294390, 27.656308, 34.199573, 50.085642, 40.132878, 57.571135, 14.339703, 36.926009, 29.554342, 30.164135, 12.484436, 27.159400, 22.706569, 0.256681, 6.911919, 4.135124, 43.760475, 49.185862, 38.182684, 25.073097, 40.337700, 38.089273, 24.701844, 39.256521, 63.218000, 42.912665, 49.607563, 10.222633, 5.090734, 41.687572, 46.727051, 45.060137, 16.797132, 26.375021, 45.732928, 40.585727, 8.286791, 35.216376, 44.661566, 44.668263, 54.235437, 25.564617, 9.707397, 53.543927, 0.629336, 46.293365, 15.177618, 43.153425, 42.473883, 29.778824, 15.561023, 57.806382, 52.793237, 64.503930, 11.431464, 61.749891, 59.903019, 9.583266, 3.799338, 35.804247, 32.855371, 41.301062, 3.802806, 7.760903, 62.308325, 57.169262, 55.002948, 0.287312, 46.488060, 11.428275, 0.177454, 8.130245, 47.989811, 9.506421, 10.092369, 22.063872, 18.481936, 10.563172, 17.414123, 36.641291, 61.303373, 20.524663, 58.708626, 58.712856, 33.223573, 26.931744, 29.813528, 8.808469, 25.723390, 50.959638, 46.878237, 30.838432, 27.596371, 46.201960, 17.075048, 60.174353, 42.610286, 47.134287, 41.363532, 29.182767, 9.554287, 43.191866, 28.156052, 48.809271, 51.568761, 48.734199, 62.287453, 1.227377, 44.438739, 9.948725, 45.922941, 59.047207, 43.105864, 25.561345, 0.093884, 45.563255, 46.551059, 15.971614, 31.593103, 20.139452, 12.602095, 11.259937, 39.495356, 8.016979, 26.911593, 14.470216, 59.771010, 20.742611, 42.657263, 64.157438, 55.670590, 46.307397, 41.455458, 63.040843, 47.302011, 19.165431, 30.394500, 25.067747, 14.504281, 1.916573, 4.328564, 11.772114, 11.603372, 45.169021, 10.257395, 1.172211, 59.373816, 9.233593, 38.739862, 6.762539, 3.546415, 43.357240, 52.730790, 30.236299, 49.755314, 19.818131, 11.164372, 39.692771, 32.470895, 24.186785, 24.159870, 48.822787, 63.778125, 33.086938, 45.209860, 56.712236, 26.535530, 42.888826, 36.213682, 52.534312, 46.204087, 32.020306, 10.666034, 13.950898, 34.630627, 43.696191, 8.543963, 44.815936, 27.013727, 64.176571, 8.520695, 42.083830, 27.322643, 19.089982, 17.967068, 11.152995, 43.251802, 23.781718, 26.002118, 56.586210, 7.741929, 30.733848, 23.514188, 25.258049, 57.861721, 13.798188, 47.257248, 36.454479, 0.450925, 41.404042, 13.488109, 20.291312, 20.955890, 27.895686, 38.880527, 50.567598, 61.141562, 21.895073, 24.499785, 20.818987, 43.644457, 0.091839, 52.814221, 43.988380, 45.578509, 10.491010, 1.622587, 35.613633, 30.692644, 48.504141, 56.972516, 54.050403, 41.554454, 49.891746, 56.874612, 33.302058, 27.765310, 63.066522, 16.764543, 21.903774, 29.254414, 50.978388, 12.958445, 17.055401, 12.856695, 5.208360, 47.339032, 45.742548, 57.315055, 2.456827, 55.833985, 10.946262, 58.208817, 0.019057, 33.003633, 47.109570, 20.383340, 62.586264, 15.255961, 42.979252, 29.680604, 44.451251, 42.860170, 50.901171, 14.257263, 12.465659, 61.361964, 9.509730, 36.686295, 14.776693, 44.852035, 49.870272, 1.688871, 53.483899, 6.878803, 41.075776, 39.444312, 22.159181, 4.967263, 45.426605, 5.894162, 1.924797, 34.904426, 38.899892, 19.022355, 39.305834, 5.315893, 25.751660, 26.933044, 63.185292, 36.724278, 4.019037, 48.197727, 36.316798, 26.475559, 36.709238, 33.832589}, 690, output, 66);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 66; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [14, 12, 5, 16, 11, 11, 9, 12, 13, 12, 14, 15, 14, 13, 11, 7, 8, 8, 12, 11, 17, 9, 11, 8, 8, 13, 9, 11, 8, 14, 17, 5, 11, 12, 13, 7, 12, 7, 9, 7, 9, 10, 15, 16, 11, 14, 16, 11, 8, 13, 11, 6, 6, 8, 8, 14, 12, 10, 6, 11, 9, 5, 9, 8, 8, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 66; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 8: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST8(void)
{
    // informacje o teście
    test_start(8, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {4, 6, 6, 5, 4, 6, 9, 10, 6, 6};
                int output[] = {2, -2, 0, 2, 2, -2, 0, -1, 1, 2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){7.610139, 0.675271, 7.537354, 7.779346, 6.127827, 9.646902, 8.475036, 10.264622, 0.777154, 10.881805, 3.854537, 0.873614, 6.398865, 8.129749, 7.304232, 5.902181, 4.176398, 2.521691, 3.633595, 4.431280, 6.044791, 2.371561, 9.442545, 10.519287, 2.804931, 2.836572, 3.667318, 10.386613, 1.888447, 3.949980, 10.110368, 6.913513, 5.085885, 1.273734, 8.760920, 8.004422, 1.266868, 7.404901, 6.632763, 6.600686, 4.929454, 7.769778, 3.138646, 9.282554, 8.488305, 4.961795, 5.387037, 10.263389, 5.619333, 0.197593, 1.606323, 5.767460, 7.936968, 10.139478, 7.067985, 6.254023, 5.756373, 7.575396, 6.785069, 9.821156, 2.177602, 1.548419, 6.472272, 10.232964, 9.568166, 1.507348, 8.131914, 7.343752, 9.883536, 2.234617}, 70, output, 10);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 10; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [4, 6, 6, 5, 4, 6, 9, 10, 6, 6]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 10; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 9: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST9(void)
{
    // informacje o teście
    test_start(9, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0};
                int output[] = {0, -2, 2, 2, -1, -1, 2, -2, 1, -2, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){9.352640}, 1, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 10: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST10(void)
{
    // informacje o teście
    test_start(10, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {7};
                int output[] = {2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){6.715171, 1.533345, 4.954886, 0.350834, 4.425020, 8.691606, 5.632111, 5.148333, 5.069126, 5.682436, 3.268970, 2.463410, 6.721931, 1.298398, 3.130578, 9.763352, 4.567400, 3.674541, 3.561414, 1.059554, 6.589432, 7.069317, 4.989080, 2.350417, 8.193309, 4.622410, 2.386433, 8.907173, 8.724050, 2.796601, 0.564209, 1.448194, 7.430228, 10.720591, 6.245402, 2.274973, 10.393260, 0.133178, 0.506100, 5.187945, 5.877643, 2.124372, 8.903159, 6.475640, 10.887400, 2.395277, 1.580222, 4.480845, 6.521591, 1.678065, 10.725819, 0.476577, 3.878913, 4.977870, 4.882599, 8.335350, 6.764115, 0.708008, 5.106407, 5.704904, 4.570756, 2.629573, 2.584854, 4.508114, 4.384306, 10.180062, 10.102926, 0.126380}, 68, output, 1);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 1; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [7]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 1; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 11: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST11(void)
{
    // informacje o teście
    test_start(11, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            printf("#####START#####");
            int res = create_histogram((float[]){9.215964, 6.264129, 5.113955, 4.841200, 9.309356, 6.994210, 9.960774}, 12, NULL, 15);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 12: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST12(void)
{
    // informacje o teście
    test_start(12, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {-1, -2, -1, 0, -1, -2, 2, 1, -2, -1, -2};

            printf("#####START#####");
            int res = create_histogram(NULL, 18, output, 16);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 13: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST13(void)
{
    // informacje o teście
    test_start(13, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {-1, -2, -1, 0, -1, -2, 2, 1, -2, -1, -2};

            printf("#####START#####");
            int res = create_histogram((float[]){9.215964, 6.264129, 5.113955, 4.841200, 9.309356, 6.994210, 9.960774}, 0, output, 15);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 14: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST14(void)
{
    // informacje o teście
    test_start(14, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {-1, -2, -1, 0, -1, -2, 2, 1, -2, -1, -2};

            printf("#####START#####");
            int res = create_histogram((float[]){9.215964, 6.264129, 5.113955, 4.841200, 9.309356, 6.994210, 9.960774}, 18, output, 0);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 15: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST15(void)
{
    // informacje o teście
    test_start(15, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {-1, -2, -1, 0, -1, -2, 2, 1, -2, -1, -2};

            printf("#####START#####");
            int res = create_histogram((float[]){9.215964, 6.264129, 5.113955, 4.841200, 9.309356, 6.994210, 9.960774}, -17, output, 20);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 16: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST16(void)
{
    // informacje o teście
    test_start(16, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {-1, -2, -1, 0, -1, -2, 2, 1, -2, -1, -2};

            printf("#####START#####");
            int res = create_histogram((float[]){9.215964, 6.264129, 5.113955, 4.841200, 9.309356, 6.994210, 9.960774}, 10, output, -12);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 17: Sprawdzanie poprawności działania funkcji display
//
void UTEST17(void)
{
    // informacje o teście
    test_start(17, "Sprawdzanie poprawności działania funkcji display", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    


                int tab[] = {-8, -3, 0, 1};

        //-------------1-----------------------
                printf("\n***TEST 1***\n\n");
                printf("***START***\n");
                display_vector(tab, 0);
                printf("***END***\n");


        //-------------2-----------------------

                printf("\n***TEST 2***\n\n");
                printf("***START***\n");
                display_vector(tab, -4);
                printf("***END***\n");

        //-------------3-----------------------

                printf("\n***TEST 3***\n\n");
                printf("***START***\n");
                display_vector(tab, 4);
                printf("***END***\n");

        //-------------4-----------------------

                printf("\n***TEST 4***\n\n");
                printf("***START***\n");
                display_vector(tab, 4 - 1);
                printf("***END***\n");

            onerror_terminate(); // przerwanie wszystkich testów jednostkowych (np. coś jest mocno nie tak z kodem)

            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 18: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST18(void)
{
    // informacje o teście
    test_start(18, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    


                const int expected_result = 5;
                const float expected_array[] = {-5.000000, 10.000000, 4.000000, 2.000000, 4.000000, 0.000000};
                float dest[6]; 
                int result = read_vector_float(dest, 6, 0);           

                test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
                int ok = 0;
                for (int i = 0; i < expected_result; ++i)
                    ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);

                test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
                if (ok)
                {
                    printf("Powinno być: [-5.000000, 10.000000, 4.000000, 2.000000, 4.000000, 0.000000]\n");
                    printf("Jest: [");
                    for (int i = 0; i < expected_result - 1; ++i)
                        printf("%f, ", dest[i]);

                    printf("%f] ", dest[expected_result - 1]);

                }

            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 19: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST19(void)
{
    // informacje o teście
    test_start(19, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    


                const int expected_result = 11;
                const float expected_array[] = {8.000000, 9.000000, 8.000000, 2.000000, -4.000000, 2.000000, 0.000000, -9.000000, 4.000000, -7.000000, 3.000000, -3.000000};
                float dest[12]; 
                int result = read_vector_float(dest, 12, -3);           

                test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
                int ok = 0;
                for (int i = 0; i < expected_result; ++i)
                    ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);

                test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
                if (ok)
                {
                    printf("Powinno być: [8.000000, 9.000000, 8.000000, 2.000000, -4.000000, 2.000000, 0.000000, -9.000000, 4.000000, -7.000000, 3.000000, -3.000000]\n");
                    printf("Jest: [");
                    for (int i = 0; i < expected_result - 1; ++i)
                        printf("%f, ", dest[i]);

                    printf("%f] ", dest[expected_result - 1]);

                }

            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 20: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST20(void)
{
    // informacje o teście
    test_start(20, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    


                const int expected_result = 0;
                const float expected_array[] = {0.000000};
                float dest[5]; 
                int result = read_vector_float(dest, 5, 0);           

                test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
                int ok = 0;
                for (int i = 0; i < expected_result; ++i)
                    ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);

                test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
                if (ok)
                {
                    printf("Powinno być: [0.000000]\n");
                    printf("Jest: [");
                    for (int i = 0; i < expected_result - 1; ++i)
                        printf("%f, ", dest[i]);

                    printf("%f] ", dest[expected_result - 1]);

                }

            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 21: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST21(void)
{
    // informacje o teście
    test_start(21, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    


                const int expected_result = 7;
                const float expected_array[] = {8.000000, 4.000000, 9.000000, 9.000000, 5.000000, -6.000000, 0.000000};
                float dest[7]; 
                int result = read_vector_float(dest, 7, -7);           

                test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
                int ok = 0;
                for (int i = 0; i < expected_result; ++i)
                    ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);

                test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
                if (ok)
                {
                    printf("Powinno być: [8.000000, 4.000000, 9.000000, 9.000000, 5.000000, -6.000000, 0.000000]\n");
                    printf("Jest: [");
                    for (int i = 0; i < expected_result - 1; ++i)
                        printf("%f, ", dest[i]);

                    printf("%f] ", dest[expected_result - 1]);

                }

            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 22: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST22(void)
{
    // informacje o teście
    test_start(22, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int expected_result = -1;
            float dest[8]; 
            printf("#####START#####");
            int result = read_vector_float(dest, 0, -3);           
            printf("#####END#####");

            test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 23: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST23(void)
{
    // informacje o teście
    test_start(23, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int expected_result = -1;
            float dest[9]; 
            printf("#####START#####");
            int result = read_vector_float(dest, -3, -5);           
            printf("#####END#####");

            test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 24: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST24(void)
{
    // informacje o teście
    test_start(24, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int expected_result = -1; 
            printf("#####START#####");
            int result = read_vector_float(NULL, -4, 3);           
            printf("#####END#####");

            test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}




enum run_mode_t { rm_normal_with_rld = 0, rm_unit_test = 1, rm_main_test = 2 };

int __wrap_main(volatile int _argc, char** _argv, char** _envp)
{
    int volatile vargc = _argc;
    char ** volatile vargv = _argv, ** volatile venvp = _envp;
    volatile enum run_mode_t run_mode = rm_unit_test; // -1
    volatile int selected_test = -1;

    if (vargc > 1)
    {
        char* smode = strtok(vargv[1], ",");
        char* stest = strtok(NULL, "");
        char *errptr = NULL;
        run_mode = (enum run_mode_t)strtol(smode, &errptr, 10);
        if (*errptr == '\x0')
        {
            memmove(vargv + 1, vargv + 2, sizeof(char*) * (vargc - 1));
            vargc--;

            if (stest != NULL)
            {
                int val = (int)strtol(stest, &errptr, 10);
                if (*errptr == '\x0')
                    selected_test = val;
            }
        }
    }

    // printf("runmode=%d; selected_test=%d\n", run_mode, selected_test);

    // inicjuj testy jednostkowe
    unit_test_init(run_mode, "unit_test_v2.c");
    test_limit_init();
    rldebug_set_reported_severity_level(MSL_FAILURE);

    if (run_mode == rm_normal_with_rld)
    {
        // konfiguracja ograniczników
        rldebug_reset_limits();
        

        // uruchom funkcję main Studenta a potem wyświetl podsumowanie sterty i zasobów
        volatile int ret_code = rdebug_call_main(tested_main, vargc, vargv, venvp);

        rldebug_reset_limits();
        

        int leaks_detected = rldebug_show_leaked_resources(0);
        if (leaks_detected)
            raise(SIGHEAP);

        return ret_code;
    }

    
    if (run_mode == rm_unit_test)
    {
        test_title("Testy jednostkowe");

        void (*pfcn[])(void) =
        { 
            UTEST1, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST2, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST3, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST4, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST5, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST6, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST7, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST8, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST9, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST10, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST11, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST12, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST13, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST14, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST15, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST16, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST17, // Sprawdzanie poprawności działania funkcji display
            UTEST18, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST19, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST20, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST21, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST22, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST23, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST24, // Sprawdzanie poprawności działania funkcji read_vector_float
            NULL
        };

        for (int idx = 0; pfcn[idx] != NULL && !test_get_session_termination_flag(); idx++)
        {
            if (selected_test == -1 || selected_test == idx + 1)
                pfcn[idx]();

            // limit niezaliczonych testów, po jakim testy jednostkowe zostaną przerwane
            if (test_session_get_fail_count() >= 1000)
                test_terminate_session();
        }


        test_title("RLDebug :: Analiza wycieku zasobów");
        // sprawdź wycieki pamięci
        int leaks_detected = rldebug_show_leaked_resources(1);
        test_set_session_leaks(leaks_detected);

        // poinformuj serwer Mrówka o wyniku testu - podsumowanie
        test_title("Podsumowanie");
        if (selected_test == -1)
            test_summary(24); // wszystkie testy muszą zakończyć się sukcesem
        else
            test_summary(1); // tylko jeden (selected_test) test musi zakończyć się sukcesem
        return EXIT_SUCCESS;
    }
    

    if (run_mode == rm_main_test)
    {
        test_title("Testy funkcji main()");

        void (*pfcn[])(int, char**, char**) =
        { 
            NULL
        };

        for (volatile int idx = 0; pfcn[idx] != NULL && !test_get_session_termination_flag(); idx++)
        {
            if (selected_test == -1 || selected_test == idx + 1)
                pfcn[idx](vargc, vargv, venvp);

            // limit niezaliczonych testów, po jakim testy jednostkowe zostaną przerwane
            if (test_session_get_fail_count() >= 1000)
                test_terminate_session();
        }


        test_title("RLDebug :: Analiza wycieku zasobów");
        // sprawdź wycieki pamięci
        int leaks_detected = rldebug_show_leaked_resources(1);
        test_set_session_leaks(leaks_detected);

        // poinformuj serwer Mrówka o wyniku testu - podsumowanie
        test_title("Podsumowanie");
        if (selected_test == -1)
            test_summary(0); // wszystkie testy muszą zakończyć się sukcesem
        else
            test_summary(1); // tylko jeden (selected_test) test musi zakończyć się sukcesem

        return EXIT_SUCCESS;
    }

    printf("*** Nieznana wartość RunMode: %d", (int)run_mode);
    abort();
}